//判断是否是IE浏览器，包括Edge浏览器
window.AESKey = '';
var tpl = [
    '<div class="browser-tips" style="margin:0 auto;text-align: center;position:fixed;bottom:0;top:0;left:0;right:0 ;width:100%;height:100%;">',
    '< img style="display: inline-block;margin:100px 0 20px 0;width:600px;" src="./img/error.jpg">',
    '<p style="font-size: 20px;color:#000;line-height: 32px;">为了给您提供更优质的网页浏览体验，建议使用IE10及以上版本的浏览器</p >',
    '<p style="font-size: 20px;color:#000;line-height: 32px;">对“协强教育”进行访问，请升级或更换其他浏览器</p >',
    '<p>360极速浏览器&nbsp;&nbsp;<a class="download" href=" ">点击下载</a ></p >',
    '</div>'
].join('');
//取得浏览器的userAgent字符串
var userAgent = navigator.userAgent;
//判断是否IE浏览器
var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1;
if (isIE) {
    var reIE = new RegExp("MSIE (\\d+\\.\\d+);");
    reIE.test(userAgent);
    var fIEVersion = parseFloat(RegExp["$1"]);
    if (fIEVersion < 10 ) {
  document.write(tpl);
  window.onload = function(){
   document.write(tpl);
  }
    }
}
$(function(){
	//每个页面都需要的右侧按钮组
    $.FloatBtn();
	var windowH = $(window).height()- 350;
	$("body").css("background-position-y",windowH)
    $(document).scroll(function(){
		var sH = windowH - $(document).scrollTop()-70  <= 0 ? "-70" : windowH - $(document).scrollTop();
		if($(document).scrollTop() > 400){
			$(".toTop").css("display","flex")
		}else{
			$(".toTop").css("display","none")
		}
		$("body").css("background-position-y",sH)
    })
//	$(".tabBtn li").mouseenter(function(){
//  	$(this).addClass("cur").siblings("li").removeClass("cur")
//  })
    $(".iconList a").each(function(i,e){
    	$(this).css("background-position-y",-i*25)
    })
	$(".miniBtn").click(function(){
		$(".miniNavCtx").css({"transform":"translateX(200px)","opacity":1});
		$(".shadow").show()
	})
	$(".shadow").click(function(){
		$(this).hide();
		$(".miniNavCtx").css({"transform":"translateX(0)","opacity":0});
	})
	
	
   
})


//每个页面都需要的右侧按钮组
$.FloatBtn = function(){
	var _html = '<div class="floatBtn">'+
					'<ul>'+
						'<li><i class="icon">&#xe69e;</i>'+
                            '<span class="tellPhone">254990991</span>' +
                        '</li>' +
						'<li>'+
							'<i class="icon">&#xe6db;</i>'+
							'<div class="weChat"><img src="img/er.png"/></div>'+
						'</li>'+
						'<li>'+
							'<i class="icon">&#xe61c;</i>'+
							'<span class="tellPhone">13488883938</span>'+
						'</li>'+
						'<li class="toTop"><i class="icon">&#xe610;</i></li>'+
					'</ul>'+
				'</div>'
	$("body").append(_html)
	var time = null;
	$(".toTop").on("click",function(){
		var toT = $(document).scrollTop();
		var speed = toT / 20 ;
		time = setInterval(function(){
			toT = toT-speed;
			$(document).scrollTop(toT)
			if(toT <= 0){
				clearInterval(time)
			}
		},15)
	})
}
/*
 * endTime:结束时间
 * 	  html:输出结构-undefined:输出默认结构
 * 	   dom:输出的父级选择器
 * */
var time = null;
$.dateTime = function(endTime,dom,html){
	var myDate = new Date();
	var ret = Date.parse(endTime) - Date.parse(myDate);
    ret = Math.round(ret / 1000)
    ret = ret >= 0 ? ret : 0;
    if(ret<=0){
    		clearInterval(time)
    }
	//转化为天-时-分-秒
    var nextshowtimeseconds = ret;
    var nexthours = parseInt(nextshowtimeseconds / 3600);
    var nextminutes = parseInt((nextshowtimeseconds - nexthours * 3600) / 60);
    var nextseconds = nextshowtimeseconds % 60;
    var nextDay = parseInt(nexthours / 24);
    nexthours 	= nexthours - nextDay * 24;
    nextDay 	= nextDay >= 10 ? nextDay : "0" + nextDay;
    nexthours 	= nexthours >= 10 ? nexthours : "0" + nexthours;
    nextminutes = nextminutes >= 10 ? nextminutes : "0" + nextminutes;
    nextseconds =nextseconds >= 10 ? nextseconds : "0" + nextseconds;
    if(!html){
    	html = 
		[
			"<p>"+nextDay+"</p>",
			"<p>"+nexthours+"</p>",
			"<p>"+nextminutes+"</p>",
			"<p>"+nextseconds+"</p>"
		].join(",").replace(/,/g,"");
    }else{

    	html = html.replace("day",nextDay).replace("hours",nexthours).replace("minutes",nextminutes).replace("seconds",nextseconds)
    }
	dom.html(html)
}
$.fn.daojishi = function(endTime,html){
	var dom = $(this);
	$.dateTime(endTime,dom,html);
	time = setInterval(function(){
		$.dateTime(endTime,dom,html);
	},1000)
}

















